﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace hpm
{
    class clsDanToc
    {
        string _maDanToc, _tenDanToc, _dienGiai;
        DAL da = new DAL();
        public DataTable dtbDanToc = null;
        SqlCommand slqcom;
        SqlDataAdapter sqlDataAdapter = null;

        public string MaDanToc
        {
            get;
            set;
        }

        public string DanToc
        {
            get;
            set;
        }

        public string DienGiai
        {
            get;
            set;
        }

        public clsDanToc()
        {
            this._maDanToc = "";
            this._tenDanToc = "";
            this._dienGiai = "";
        }


        public DataTable getAllDanToc()
        {
            da.ketnoiServer();
            dtbDanToc = new DataTable();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select MaDanToc, DanToc from DMDanToc order by DanToc";
            this.slqcom.Connection = da.con;
            this.slqcom.CommandType = CommandType.Text;
            this.sqlDataAdapter = new SqlDataAdapter(this.slqcom);
            this.sqlDataAdapter.Fill(dtbDanToc);
            //da.da_closeConnect();
            return dtbDanToc;
        }

        public string getMacDinh()
        {
            da.ketnoiServer();
            this.slqcom = new SqlCommand();
            this.slqcom.CommandText = "Select DanToc from DMDanToc WHERE MacDinh = 1";
            this.slqcom.Connection = da.con;
            SqlDataReader reader = slqcom.ExecuteReader();
            reader.Read();
            return reader[0].ToString();
        }

    }
}
